package com.guoxin.chapter3.waitnotify.pipedinputoutput;

import java.io.IOException;
import java.io.PipedInputStream;

public class ReadData {
	public void readMethod(PipedInputStream in) {
		try {
			System.out.println("read:");
			byte[] byteArray = new byte[20];
			int readLenght = in.read(byteArray);
			while (readLenght != -1) {
				String newData = new String(byteArray, 0, readLenght);
				System.out.print(newData);
				readLenght = in.read(byteArray);
			}
			System.out.println();
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
